<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <title>刘功明泡妞记</title>
</head>
<body>
  <script>
  // alert('先取功明，再成家');
  // 对象 
  class Flower {
    constructor(type, n) { //构造函数 new 运行
      this.type = type; //属性
      this.n = n;
    }
  }
  var gongming = {
    name: '刘功明',
    age: 21,
    favorites: ['代码', '看书', '打搀'],
    room: 1114,
    yz: 70,
    hometown: '赣州兴国',
    isSingle: true,
    sendFlower: function(target) {
      var flower = new Flower('红玫瑰', 11);
      console.log(flower.type, flower.n);
      target.receiveFlower(this, flower);
    }
  }
  var xiaohong = {
    name: '小红',
    age: 18,
    isGoodmod:false,
    receiveFlower: function(sender, flower) {
      if (!this.isGoodmod) {
        console.log('丑拒,娘娘心情不好');
      } else {
        console.log('万达走一波');
      }
      // console.log(sender, flower);
    }
  }
  
  var xiaomei = {
    hometown: '赣州兴国',
    receiveFlower:function(sender, flower) {
      setTimeout(function(){
            xiaohong.isGoodmod=ture;
            xiaohong.receiveFlower(sender, flower);
      },1000);
    }
  }
  gongming.sendFlower(xiaomei);
  </script>
</body>
</html>